<!--
 * @Author: 471826078@qq.com
 * @Date: 2020-05-14 10:40:24
 * @LastEditors: younghxp
 * @LastEditTime: 2022-03-18 17:59:05
-->
<template>
  <div class="container">
    <el-link
      style="float: right; margin: 10px 24px 0 0; z-index: 1000"
      type="primary"
      @click="goHistory"
      v-sdc
      class="fontBtn"
      >历史记录</el-link
    >
    <operateListTab
      @getSelected="getCurrentTabComponent"
      :groupList="groupList"
    ></operateListTab>
    <component
      v-bind:is="currentTabComponent"
      :type="componentType"
      :projectId="projectId"
    ></component>
  </div>
</template>

<script>
import operateListTab from '@/components/publicCom/operateListTab'
import constructAttByDay from '@/components/constructAttendance/constructAttByDay'
import constructAttByMonth from '@/components/constructAttendance/constructAttByMonth'
import constructAttByYear from '@/components/constructAttendance/constructAttByYear'
import paymentRatio from '@/components/cashDeposit/paymentRatio'

export default {
  components: {
    operateListTab,
    constructAttByDay,
    constructAttByMonth,
    constructAttByYear,
    paymentRatio,
  },
  props: ['employeeName', 'projectId'],
  data() {
    return {
      currentTabComponent: 'constructAttByDay',
      componentType: '',
      //   titleText: "保证金设置",
      groupList: [
        { name: '按日统计', componentName: 'constructAttByDay' },
        {
          name: '按月统计',
          componentName: 'constructAttByMonth',
          componentType: 'month',
        },
        {
          name: '按年统计',
          componentName: 'constructAttByYear',
          componentType: 'year',
        },
      ],
    }
  },
  created() {},
  methods: {
    goHistory() {
      const path = '/home/smallProjectManage/attendanceAttachRecordPage'
      const backPath = '/home/monitorProjectManagement/projectDetail'
      const oldUrl =
        this.$store.state.userType === 'MONITOR'
          ? '/home/project/projectList'
          : '/home/project/projectListQY'
      this.$router.push({
        path,
        query: {
          oldUrl,
          projectId: this.projectId,
          backPath,
        },
      })
      this.$store.commit('CHANGE_SLIDER_NAME', {
        oldUrl,
        newUrl: this.$router.currentRoute.fullPath,
      })
    },
    // 获取子组件上传成功后的值
    getCurrentTabComponent(data) {
      this.currentTabComponent = data.componentName
      this.componentType = data.componentType
    },
  },
}
</script>

<style scoped lang="less">
.container {
  padding-top: 24px;
}
</style>
